import { getDetailListRequest } from "@/api";

//detail的store模块化
const state = {
  detailList: {},
};
const mutations = {
  SET_DETAILIST(state, value) {
    state.detailList = value;
  },
};
const actions = {
  async getDetailList({ commit }, skuId) {
    const result = await getDetailListRequest(skuId);
    commit("SET_DETAILIST", result);
  },
};
const getters = {
  categoryView() {
    return state.detailList.categoryView || {};
  },
  skuInfo() {
    return state.detailList.skuInfo || {};
  },
  spuSaleAttrList() {
    return state.detailList.spuSaleAttrList || [];
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
